/**
 * 
 */
package com.repository.validation;

import org.springframework.util.StringUtils;
import org.springframework.validation.Errors;

import com.repository.model.User;

/**
 * Validates User object. User's mendatory fields are looked up for
 * any errors and suitable errors are reported
 * @author lovkeshsingh
 */
public class UserValidator {

	public void validate(User user, Errors errors) {
		
		
		if (!StringUtils.hasLength(user.getUserName())) {
			errors.rejectValue("description", "required", "required");
		}
		
		if (!StringUtils.hasLength(user.getPassword())) {
			errors.rejectValue("description", "required", "required");
		}
		
	}
}
